//
//  LBQuadTexture.mm
//  OpenGLGame
//
//  Created by Nguyen Cong Huy on 4/15/13.
//  Copyright (c) 2013 UIT. All rights reserved.
//

#include "LBQuadTexture.h"
#include "Matrix.h"

LBQuadTexture::LBQuadTexture():LBTexture(){
    setDesCoor(0, 0, 0, height, width, 0, width, height);
}

LBQuadTexture::LBQuadTexture(int width, int height):LBTexture(width, height){
    setDesCoor(0, 0, 0, height, width, 0, width, height);
}

LBQuadTexture::LBQuadTexture(const unsigned char* imageData, int width, int height):
LBTexture(imageData, width, height){
    setDesCoor(0, 0, 0, height, width, 0, width, height);
}

LBQuadTexture::LBQuadTexture(const unsigned char* imageData, int width, int height, int bytePerPixel)
:LBTexture(imageData, width, height, bytePerPixel){
    setDesCoor(0, 0, 0, height, width, 0, width, height);
}

void LBQuadTexture::calculateMatrix(){
    mWorld->LoadIdentity();
}

void LBQuadTexture::setDesCoor(float leftTopX, float leftTopY, float leftBottomX, float leftBottomY, float rightTopX, float rightTopY, float rightBottomX, float rightBottomY){
    this->leftTopX = leftTopX;
    this->leftTopY = leftTopY;
    this->leftBottomX = leftBottomX;
    this->leftBottomY = leftBottomY;
    this->rightTopX = rightTopX;
    this->rightTopY = rightTopY;
    this->rightBottomX = rightBottomX;
    this->rightBottomY = rightBottomY;
}

void LBQuadTexture::calculateVertices(){
    imageVertices[0] = leftBottomX;
    imageVertices[1] = leftBottomY;
    imageVertices[2] = rightBottomX;
    imageVertices[3] = rightBottomY;
    imageVertices[4] = leftTopX;
    imageVertices[5] = leftTopY;
    imageVertices[6] = rightTopX;
    imageVertices[7] = rightTopY;
}